for _ in ' '*int(input()): print(sum(map(len, sorted(input().split('0'))[::-2])))
#include<stdio.h>
#include<string.h>
int main()
{
int n;
scanf("%d",&n);
int i,j,k;
while(n--)
{
char a[101];
j=0;
int b[100]={0};
scanf(" %s",a);
int b1=strlen(a);
int o=0,f=0;
i=0;
while(a[i]!='1')
{
i++;
if(i==b1)
{
f=1;
break;
}
}
if(f==1)
{
printf("0\n");
continue;
}
for(;i<b1;i++)
{
if(a[i]=='1')
{
b[j]++;
o++;
}
else if( a[i]=='0' && a[i+1]=='1')
{
j++;
}
}
b[j+1]='\0';
int s=j+1;
// printf("%d\n",s);
for(i=0;i<s;i++)
{
for(j=0;j<s-1;j++)
{
if(b[j]<b[j+1])
{
int temp=b[j];
b[j]=b[j+1];
b[j+1]=temp;
}
}
}
int a1=0;
for(i=0;i<s;i=i+2)
{
a1=a1+b[i];
}
printf("%d\n",a1);
}
}
1650A - Deletions of Two Adjacent Letters | 1512A - Spy Detected |
282A - Bit++ | 69A - Young Physicist |
1651A - Playoff | 734A - Anton and Danik |
1300B - Assigning to Classes | 1647A - Madoka and Math Dad |
710A - King Moves | 1131A - Sea Battle |
118A - String Task | 236A - Boy or Girl |
271A - Beautiful Year | 520B - Two Buttons |
231A - Team | 479C - Exams |
1030A - In Search of an Easy Problem | 158A - Next Round |
71A - Way Too Long Words | 160A - Twins |
1A - Theatre Square | 1614B - Divan and a New Project |
791A - Bear and Big Brother | 1452A - Robot Program |
344A - Magnets | 96A - Football |
702B - Powers of Two | 1036A - Function Height |
443A - Anton and Letters | 1478B - Nezzar and Lucky Number |